#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "linechart.h"
#include "nightcharts.h"
#include <QtCore>
#include <QtGui>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
//    ui->setupUi(this);

//    LineChart linechart;
//    linechart.dataInput(0,20,30);
//    linechart.dataInput(10,2,30);
//    linechart.dataInput(10,29,100);
//    linechart.dataInput(20,33,30);
//    linechart.dataInput(10,11,30);
//    linechart.dataInput(20,11,30);
//    linechart.dataInput(30,11,30);
//    linechart.dataInput(10,11,30);
//    linechart.dataInput(20,11,30);
//    linechart.dataInput(1,11,30);
//    linechart.dataInput(6,11,30);
//    linechart.dataInput(8,11,30);
//    linechart.draw();
//    ui->label->setPixmap(QPixmap("./test.png"));
    QString id("white");
    QPixmap pixmap(700,900);
    pixmap.fill(QColor(id).rgba());

    // write the color name
    QFont font;
    font.setPixelSize(24);
    QPainter painter(&pixmap);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setFont(font);
    painter.drawText(100, 30, "中文");
    Nightcharts PieChart;
    PieChart.setType(Nightcharts::Dpie);//{Histogramm , Pie, Dpie};
    PieChart.setLegendType(Nightcharts::Vertical);//{Round,Vertical}
    PieChart.setCords(50,50,600,500);
    PieChart.addPiece("Item1",QColor(200,10,50),34);
    PieChart.addPiece("Item2",Qt::green,27);
    PieChart.addPiece("Item3",Qt::cyan,14);
    PieChart.addPiece("Item4",Qt::yellow,7);
    PieChart.addPiece("中文5",Qt::blue,4);
    PieChart.draw(&painter);
    PieChart.drawLegend(&painter);
    pixmap.save("./test.png", "PNG");
}

MainWindow::~MainWindow()
{
    delete ui;
}
